package com.hosever.action;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class WifeZone {

	public static void main(String[] args) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
		FatYo fatYo = new FatYo();
		FatYoService fatYoService = new FatYoService();
		System.out.println(fatYo.getOriginalName());
		System.out.println("出生日期："+sdf.format(fatYo.getBirthDay()));
		System.out.println("年龄："+fatYoService.getAgeString());
		
		System.out.println();
		Date today = new Date();
		long ms = today.getTime()-fatYo.getFollowInLove().getTime();
		long day = ms/(1000*60*60*24);
		System.out.println("在一起共"+day+"天");
		System.out.println("分手费（按500元/天）,共"+day*500+"元");
		
	}
}

class FatYoService{
	FatYo fatYo = new FatYo();
	
	public void getInfo(){
		
	}
	
	/**
	 * 获取年龄
	 * @return
	 */
	public int getAge(){
		Calendar today = Calendar.getInstance();
		Calendar wifeBirthDay = Calendar.getInstance();
		wifeBirthDay.setTime(fatYo.getBirthDay());
		long ms = today.getTime().getTime()-wifeBirthDay.getTime().getTime();
		int year = (int) (ms/(1000*60*60*24)/365);
		
		return year;
	}
	/**
	 * 获取年龄串
	 * @return
	 */
	public String getAgeString(){
		Calendar today = Calendar.getInstance();
		Calendar thisYearBirthDay = Calendar.getInstance();
		thisYearBirthDay.setTime(fatYo.getBirthDay());
		thisYearBirthDay.set(Calendar.YEAR, today.get(Calendar.YEAR));
		Calendar wifeBirthDay = Calendar.getInstance();
		wifeBirthDay.setTime(fatYo.getBirthDay());
		
		int year = 0;
		int month = 0;
		int day = 0;
		if(today.after(thisYearBirthDay)){
			year = today.get(Calendar.YEAR)-wifeBirthDay.get(Calendar.YEAR);
			month = (today.get(Calendar.MONTH)-wifeBirthDay.get(Calendar.MONTH));
		}else{
			year = today.get(Calendar.YEAR)-wifeBirthDay.get(Calendar.YEAR)-1;
			month = (today.get(Calendar.MONTH)-wifeBirthDay.get(Calendar.MONTH))+12;
		}
		
		Calendar lastMonth = Calendar.getInstance();
		lastMonth.set(Calendar.DATE, 0);
		lastMonth.add(Calendar.DATE, -1);
		if(today.get(Calendar.DATE)>=wifeBirthDay.get(Calendar.DATE)){
			day = today.get(Calendar.DATE) - wifeBirthDay.get(Calendar.DATE);
		}else{
			day = today.get(Calendar.DATE)+(lastMonth.get(Calendar.DATE)-wifeBirthDay.get(Calendar.DATE));
		}
		
		String result = year +"岁" + month + "个月" + day +"天";
		return result;
	}
}
